<?php
session_start();
$loginId=$_SESSION['loginid'];
$name=$_SESSION['name'];
$userType=$_SESSION['user_type'];
$typeScheme=$_SESSION['type_scheme'];
include("connection/connection.php");
include("config.php");
$source_id=$_REQUEST['var'];
$reference_id=$_REQUEST['referenceId'];
$qrSource="select * from tbl_dtls_q1_sws where id='$source_id'";
		$resSource=mysql_query($qrSource);
		$rowSource=mysql_fetch_array($resSource);
		$loc_id=$rowSource['loc_id'];
?>
<script language="javascript">
function setReadOnly22(valobj)
{
		//document.getElementById('household'+obj).style.backgroundcolor="#eeeeee";
		//document.getElementById('population_sc1').readonly=1;
		//document.getElementById('population_sc1').value="Not Applicable";
		document.getElementById('yeildMin').disabled=true;
		document.getElementById('yeildMax').disabled=true;
		document.getElementById('waterMin').disabled=true;
		document.getElementById('waterMax').disabled=true;
		document.getElementById('pH').disabled=true;
		document.getElementById('TDS').disabled=true;
		document.getElementById('cl').disabled=true;
		document.getElementById('F').disabled=true;
		document.getElementById('no3').disabled=true;
		//document.getElementById('source'+obj).disabled=true;
		document.getElementById('source_status').value="defunct";
   
}
function setEnable22(valobj)
{

		//document.getElementById('population_sc1').style.backgroundcolor="#ffffff";
		//document.getElementById('population_sc1').readonly=0;
		//document.getElementById('population_sc1').value="";
		document.getElementById('yeildMin').disabled=false;
		document.getElementById('yeildMax').disabled=false;
		document.getElementById('waterMin').disabled=false;
		document.getElementById('waterMax').disabled=false;
		document.getElementById('pH').disabled=false;
		document.getElementById('TDS').disabled=false;
		document.getElementById('cl').disabled=false;
		document.getElementById('F').disabled=false;
		document.getElementById('no3').disabled=false;
		//document.getElementById('source'+obj).disabled=false;
		document.getElementById('source_status').value="operation";
	
}

</script>
<script>
addCalendar("Calendar3", "Select Date", "testing_date", "sec3");
 setWidth(90, 1, 15, 1);
 setFormat("yyyy-mm-dd");
</script>
 <div class="section_format">
  <form action="source_edit.php" method="post" name="sec3" id="sec3" onsubmit="return sec3_val();">
  <div style="height:30px" align="center"><?php echo $reference_id;?></div>
  <table border="1">
    
    <tr>
      <td width="400">&nbsp;<b>Source</b>
	  <input type="hidden" name="frmId" id="frmId" value="<?php echo $loc_id;?>" />
	  <input type="hidden" name="loginId" id="loginId" value="<?php echo $loginId;?>" />
	  <input type="hidden" name="name" id="name" value="<?php echo $name;?>" />
	  <input type="hidden" name="userType" id="userType" value="<?php echo $userType;?>" />
	  <input type="hidden" name="typeScheme" id="typeScheme" value="<?php echo $typeScheme;?>" />
	  </td>
      <td width="400">&nbsp;
	  <select size="1" name="source" id="source" class="txt">
						<option selected value="0">Select Source</option>
						<?php 
						foreach($sources as $key=>$val)
						{
							//echo "$rowSource[source]";
							if($val==$rowSource[source])
							{
		   						echo "<option value=\"$val\" selected>$val</option>";
							}
							else
							{
								echo "<option value=\"$val\">$val</option>";
							}
						}
						?>
				  </select>
	  <?php //echo "$rowSource[source]";?></td>
      </tr>
   
      <td>&nbsp;<b>Location</b></td>
      <td>&nbsp;<input type="text" name="Location" id="Location" value="<?php echo $rowSource['location'];?>" /><input type="hidden" id="sourceId" name="sourceId" value="<?php echo $source_id; ?>"></td>
      </tr>
   
	  <tr>
      <td>&nbsp;<b>Latitude</b></td>
      <td>&nbsp;<input type="text" name="Latitude" id="Latitude" value="<?php echo $rowSource['latitude'];?>" onBlur="float1(this,20,32);" /></td>
      </tr>
	   <tr>
      <td>&nbsp;<b>Longitude</b></td>
      <td>&nbsp;<input type="text" name="Longitude" id="Longitude" value="<?php echo $rowSource['longitude'];?>"  onBlur="float1(this,67,80);" /></td>
      </tr>
	   <tr>
      <td>&nbsp;<b>Current status</b></td>
      <td>&nbsp;
	  <?php
	  if($rowSource['current_status']=="operation")
	  {
	  ?>
	  <input type="radio" id="source_status_op" name="source_status" value="operation" checked="checked" onClick="setEnable22(this.value)">&nbsp;OPERATIONAL&nbsp;&nbsp;<input type="radio" id="source_status" name="source_status" value="defunct" onClick="setReadOnly22(this.value)">&nbsp;DEFUNCT
	  <?php
	  }else{
	  ?>
	  <input type="radio" id="source_status_op" name="source_status" value="operation" onClick="setEnable22(this.value)">&nbsp;OPERATIONAL&nbsp;&nbsp;<input type="radio" id="source_status" name="source_status" value="defunct" checked="checked" onClick="setReadOnly22(this.value)">&nbsp;DEFUNCT
	  <?php
	  }
	  ?>
	  </td>
      </tr>
    <tr>
	  <tr>
      <td>&nbsp;<b>Yield (Min) KL/day</b></td>
      <td>&nbsp;<input type="text" name="yeildMin" id="yeildMin" value="<?php printf("%d",$rowSource['yield_min']); ?>"  <?php if($rowSource['current_status']!="operation")
	  { echo "disabled";}else{ echo "";}?>  /></td>
      </tr>
	  <tr>
      <td>&nbsp;<b>Yield (Max) KL/day</b></td>
      <td>&nbsp;<input type="text" name="yeildMax" id="yeildMax" value="<?php  printf("%d",$rowSource['yield_max']); ?>" <?php if($rowSource['current_status']!="operation")
	  { echo "disabled";}else{ echo "";}?> /></td>
      </tr>
	  <tr>
      <td>&nbsp;<b>Water Table (Min) (M)</b></td>
      <td>&nbsp;<input type="text" name="waterMin" id="waterMin" value="<?php printf("%d",$rowSource['water_table_min']); ?>" <?php if($rowSource['current_status']!="operation")
	  { echo "disabled";}else{ echo "";}?> /></td>
      </tr>
	  <tr>
      <td>&nbsp;<b>Water Table (Max) (M)</b></td>
      <td>&nbsp;<input type="text" name="waterMax" id="waterMax" value="<?php printf("%d",$rowSource['water_table_max']); ?>" <?php if($rowSource['current_status']!="operation")
	  { echo "disabled";}else{ echo "";}?> /></td>
      </tr>
	   <tr bgcolor="#999999">
	    <td colspan="2"><b>Water Quality Parameter</b></td>
      </tr>
	   <tr>
      <td>&nbsp;<b>pH</b></td>
      <td>&nbsp;<input type="text" name="pH" id="pH" value="<?php echo $rowSource['pH'];?>" <?php if($rowSource['current_status']!="operation")
	  { echo "disabled";}else{ echo "";}?>  onBlur="check1(this,6,10);" /></td>
      </tr>
	   <tr>
      <td>&nbsp;<b>TDS (mg/l)</b></td>
      <td>&nbsp;<input type="text" name="TDS" id="TDS" value="<?php echo $rowSource['TDS'];?>" <?php if($rowSource['current_status']!="operation")
	  { echo "disabled";}else{ echo "";}?> onBlur="check(this,100,40000);" /></td>
      </tr>
	   <tr>
      <td>&nbsp;<b>Cl (mg/l)</b></td>
      <td>&nbsp;<input type="text" name="cl" id="cl" value="<?php echo $rowSource['Cl'];?>" <?php if($rowSource['current_status']!="operation")
	  { echo "disabled";}else{ echo "";}?>  onBlur="check(this,50,15000);" /></td>
      </tr>
	   <tr>
      <td>&nbsp;<b>F (mg/l)</b></td>
      <td>&nbsp;<input type="text" name="F" id="F" value="<?php echo $rowSource['F'];?>" <?php if($rowSource['current_status']!="operation")
	  { echo "disabled";}else{ echo "";}?> onBlur="check1(this,0,18);" /></td>
      </tr>
	   <tr>
      <td>&nbsp;<b>NO<sub>3</sub> (mg/l)</b></td>
      <td>&nbsp;<input type="text" name="no3" id="no3" value="<?php echo $rowSource['no3'];?>" <?php if($rowSource['current_status']!="operation")
	  { echo "disabled";}else{ echo "";}?> onBlur="check(this,0,2500);"/></td>
      </tr>
	  <td>&nbsp;<b>Testing/Sampling Date</b></td>
      <td>&nbsp;<input type="text" name="testing_date" id="testing_date" value="<?php echo $rowSource['testing_date'];?>" readonly />&nbsp;<a href="javascript:showCal('Calendar3')"><img src="images/caldr.jpg" /></a></td>
	  <tr>
	    <td colspan="2" align="center"> <input type="submit" value="EDIT" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 1px; font-weight:bold; background:#666666; color:#FFFFFF; width:140px; height:30px" onClick="view_validate()"></td>
  </tr>
  </table>
  </form>
  </div>